package com.yeung.alo;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * abc Abc 123 1 1bc CBD abcd a
 */
public class 字符串排序 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        String[] strs = line.split(" ");
        Arrays.sort(strs, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                int len1 = o1.length();
                int len2 = o2.length();
                if (len1 != len2) return len1 - len2;
                else {
                    //相同长度
                    char[] ch1 = o1.toCharArray();
                    char[] ch2 = o2.toCharArray();
                    int result = 0;
                    for (int i = 0; i < ch2.length; i++) {
                        char c1 = ch1[i];
                        char c2 = ch2[i];
                        if (c1 != c2) {
                            int number1 = isNumber(c1);
                            int number2 = isNumber(c2);
                            if (number1 != -1 && number2 != -1) {
                                //都是数字
                                result = number1 - number2;
                                if (result != 0) break;//比较出大小了
                            } else if (number1 == -1 && number2 != -1) {
//                                number1不是数字
//                                number1 = (int) c1;

                                result = -1;
                                break;
                            } else if (number1 != -1 && number2 == -1) {
//                                number1是数字
                                result = 1;
                                break;
                            } else {
                                //都不是数字
//                                abc Abc CBD
                                int n1 = (int) c1;
                                int n2 = (int) c2;
                                if (n1 >= 97)
                                    n1 -= 33;
                                if (n2 >= 97)
                                    n2 -= 33;
                                if (n1 == n2) {
                                    result = 1;
                                    break;

                                } else {
                                    result = n1 - n2;
                                    break;//比较出大小了
                                }
                            }
                        }

                    }
                    return result;
                }
            }
        });
        for (String str : strs) {
            System.out.print(str + " ");
        }

    }

    private static int isNumber(char str) {
        int value = (int) str;
        if (value <= 57 && value >= 48) {
            return Integer.valueOf(str + "");
        } else return -1;
    }
}
